package tests 
{
	import org.flixel.*;
	import com.photonstorm.flixel.*;
	
	public class TestsHeader extends FlxGroup
	{
		[Embed(source = '../../assets/flixel_power_tools_logo.png')] private var logoPNG:Class;
		[Embed(source = '../../assets/back_button_up.png')] private var backUpPNG:Class;
		[Embed(source = '../../assets/back_button_down.png')] private var backDownPNG:Class;
		
		private var logo:FlxSprite;
		private var backButton:FlxButton;
		public var instructions:FlxText;
		
		public function TestsHeader(text:String, showButton:Boolean = true) 
		{
			super();
			
			logo = new FlxSprite(0, 3, logoPNG);
			logo.x = FlxG.width / 2 - logo.width / 2;
			logo.scrollFactor.x = 0;
			logo.scrollFactor.y = 0;
			
			var background:FlxSprite = FlxGradient.createGradientFlxSprite(320, 240, [0x004080, 0x3C3CFF], 10);
			FlxGridOverlay.overlay(background, 16, 16, 320, 240, false, true, 0x44e7e6e6, 0x44d9d5d5);
			
			instructions = new FlxText(0, FlxG.height - 16, 320, text);
			instructions.alignment = "center";
			instructions.shadow = 0x000001;
			
			add(background);
			add(logo);
			add(instructions);
			
			if (showButton)
			{
				backButton = new FlxButton(303, 2, backToMenu);
				
				var buttonUp:FlxSprite = new FlxSprite(0, 0, backUpPNG);
				var buttonDown:FlxSprite = new FlxSprite(0, 0, backDownPNG);
				
				backButton.loadGraphic(buttonUp, buttonDown);
			
				add(backButton);
			}
		}
		
		private function backToMenu():void
		{
			if (FlxFlod.isPlaying)
			{
				FlxFlod.stopMod();
			}
			
			FlxG.state = new TestSuiteState;
		}
		
	}

}